package com.gan.simple_init.model.user.dto;

import cn.hutool.crypto.Mode;
import cn.hutool.crypto.Padding;
import cn.hutool.crypto.symmetric.AES;
import com.gan.simple_init.common.constant.UserConstant;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotBlank;
import java.nio.charset.StandardCharsets;
import java.util.Base64;

/**
 * @author gbw
 * @date 2023/8/9
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserLoginDTO {

    @NotBlank(message = "用户名不能为空!")
    private String userName;

    @NotBlank(message = "密码不能为空!")
    private String password;


    /**
     * 用于输出加密后的密码
     * @param args
     */
    public static void main(String[] args) {
        // 加密明文密码
        AES aes = new AES(Mode.ECB, Padding.PKCS5Padding, UserConstant.SALT.getBytes());
        System.out.println(aes.encryptBase64("123456"));
        // 解密加密后的密码
        System.out.println(aes.decryptStr("KmyK0YszvXL5AVYeX45TLA=="));
    }
}
